<?php $paginator = $this->Paginator; ?>

<section id="Analyst">
    <div class="page-head">
        <div class="container">
            <div class="row">
                <div class="span9 head-text">
                    <h3><span><?php echo $company['Company']['name'] ?></span></h3>
                    <p><i class="icon-quote-left icon64 alignleft"></i><?php echo $company['Company']['short_description'] ?></p>
                    <div class="span9 head-content"><?php echo $company['Company']['description'] ?></div>
                </div>
                <div class="span3">
                    <i class="icon icon-play-sign"></i>
                </div>						
            </div>
        </div>			
    </div>
    <div class="container">
        <div class="page-section">
            <div class="row">
                <div class="span12 aligncenter">

                    <?php
                    $text_display = '';
                    foreach ($rows as $row) :
                        $right = $wrong = 0;
                        if ($row['Broker']['opinions']) {
                            $total_opinions = sizeof($row['Broker']['opinions']);
                            $total_right = 0;
                            foreach ($row['Broker']['opinions'] as $opinion) {
                                if ($opinion['Opinion']['result'] == 1) {
                                    $total_right++;
                                }
                            }

                            $right = number_format(($total_right / $total_opinions) * 100);
                            $wrong = 100 - $right;
                        }

                        $text_display .='<div class="services-box services-bg1 e_bounce">'
                                . '<h5>' . $row['Broker']['fullname'] . '</h5>'
                                . '<p>Performance <br><br>'
                                . '<span id="green" style="display: block; width:' . $right . '%; background-color:#093;">' . $right . '%</span>'
                                . '<span id="red" style="display: block; width:' . $wrong . '%; background-color:rgba(204,51,0,1);">' . $wrong . '%</span>'
                                . '</p>'
                                . $this->Html->link('View Profile', '/analyst/view/' . $row['Broker']['id'], array('class' => 'btn btn-primary'))
                                . '</div>';

                    endforeach;
                    ?>

                    <?php echo $text_display; ?>      

                    <div class="span12 pagination">
                        &nbsp;
                        <ul>
                            <?php
                            if ($paginator->hasPrev()) {
                                echo '<li>' . $paginator->prev("Prev") . '</li>';
                            }
                            ?>
                            <?php echo $paginator->numbers(array('modulus' => 3, 'tag' => 'li', 'separator' => '', 'currentTag' => 'a', 'currentClass' => 'active')); ?>
                            <?php
                            if ($paginator->hasNext()) {
                                echo '<li>' . $paginator->next("Next") . '</li>';
                            }
                            ?>
                        </ul>
                    </div>
                </div>

            </div>
        </div>
    </div>
</section>